using UnityEngine;
using System.Collections;

public class Grenade : MonoBehaviour 
{
    public float speed = 0.7f;
    public int damage;

    void Start()
    {
        Destroy(gameObject, 2);
    }
    
    void Update()
    {
        transform.Translate(Vector3.forward * speed);
    }

    void OnTriggerEnter(Collider other)
    {
        if(other.gameObject.tag == "Character")
        {
            CharMovement player = other.gameObject.transform.parent.GetComponent<CharMovement>();
            player.removeHP(damage);
            Destroy(gameObject);
        }
    }
}
